04 Exibindo o progresso

Próxima Atividade
  • Sugerir melhoria
Play
Current Time 0:00
/
Duration Time 0:00
Remaining Time -0:00
Stream TypeLIVE
Loaded: 0%
Progress: 0%
0:00
Fullscreen
00:00
Mute
Playback Rate
  • 2x
  • 1.5x
  • 1.2x
  • 1x
  • 0.8x
  • 0.7x
1x
Subtitles
  • subtitles off
Captions
  • captions off
Chapters
  • Chapters
HD
Desculpe-nos pelo transtorno, mas este video não pode ser carregado, tente novamente.

Transcrição

  upload() {
    const description = this.photoForm.get('description').value;
    const allowComments = this.photoForm.get('allowComments').value;
    this.photoService
      .upload(description, allowComments, this.file)
      .subscribe((event: HttpEvent<any>) => {
        if (event.type === HttpEventType.UploadProgress) {
          this.percentDone = Math.round(100 * event.loaded / event.total);
        } else if (event instanceof HttpResponse) {
          this.alertService.success('Upload complete', true);
          this.router.navigate(['/user', this.userService.getUserName()]);
        }
      });
  }
      <div *ngIf="!percentDone; else percent" >
        <button 
            [disabled]="photoForm.invalid" 
            type="submit" 
            class="btn btn-primary btn-block">
            Upload
        </button>
        <a [routerLink]="['']" class="btn btn-secondary btn-block">Cancel</a>
      </div>

      <ng-template #percent>
        <div class="text-center display-4" *ngIf="percentDone">
          uploading {{ percentDone }}%
        </div>
      </ng-template>
Tirar dúvida Próxima Atividade
ícone Angular parte 4: lapidando o projeto

Angular parte 4: lapidando o projeto

98%
Aula02 de 07

Upload e progresso

Atividades 4 de 7

  • 01 Projeto da aula anterior
  • 02 Adequando a camada de serviço 03min
  • 03 Progresso
  • 04 Exibindo o progresso 13min
  • 05 O operador finalize
  • 06 Exibição do progresso
  • 07 Consolidando seu conhecimento

Aulas

Outros Links

Fórum Trocar Curso
Gravatar de Marcos Katsumi Kay

Marcos Katsumi Kay 34.4k xp

Logo da Alura